package com.elink.enginerring.file;

import java.util.Map;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.elink.enginerring.common.BaseCo;
import com.elink.enginerring.datasource.DataSourceContextHolder;
import com.elink.enginerring.datasource.DataSourceType;
import com.elink.enginerring.file.service.ICommentService;

@RestController
@RequestMapping("/file/comment")
public class FileCommentController {
	@Autowired
	private ICommentService commentService;

	/**
	 * 分页获取列表
	 * @param bc
	 * @param type 0--审核中 1--已经审核 2--未通过审核
	 * @return
	 */
	@RequestMapping(value = "/getList", method = RequestMethod.GET)
	public Map<String, Object> getList(@ModelAttribute @Valid BaseCo bc,@RequestParam("type")String type) {
		DataSourceContextHolder.setDbType(DataSourceType.DBDATABASE);
		System.out.println("选择的数据库" + DataSourceContextHolder.getDbType());
		return commentService.getListOfPage(bc,type);
	}
	
	/**
	 * 审核评论
	 * @param ids
	 * @return
	 */
	@RequestMapping(value="addAuth",method=RequestMethod.GET)
	public Map<String, Object>addAuth(
	@RequestParam(value="ids",required=true)String ids,
	@RequestParam(value="authStatus",required=true,defaultValue="0")int authStatus){
		DataSourceContextHolder.setDbType(DataSourceType.DBDATABASE);
		System.out.println("选择的数据库" + DataSourceContextHolder.getDbType());
		return commentService.addAuth(ids,authStatus);
	}
}
